#! /bin/bash
export LANG=zh_CN.UTF-8
PRESTO_HOME=/export/server/presto/bin/presto


${PRESTO_HOME} --catalog hive --server 192.168.88.80:8090 --execute "
insert into hive.edu_rpt.rpt_relationship_customer
select
dt,
year_code,
year_month,
time_type,
origin_type,
clue_state,
nums_count
from hive.edu_dm.edu_dm_relationship_count;

insert into hive.edu_rpt.rpt_relationship_area_customer
select
dt,
year_code,
year_month,
time_type,
origin_type,
clue_state,
area,
nums_count
from hive.edu_dm.edu_dm_relationship_count;

insert into hive.edu_rpt.rpt_relationship_subject_customer
select
dt,
year_code,
year_month,
time_type,
origin_type,
clue_state,
subject_name,
nums_count
from hive.edu_dm.edu_dm_relationship_count;

insert into hive.edu_rpt.rpt_relationship_school_customer
select
dt,
year_code,
year_month,
time_type,
origin_type,
clue_state,
school_name,
nums_count
from hive.edu_dm.edu_dm_relationship_count;

insert into hive.edu_rpt.rpt_relationship_origin_channel_customer
select
dt,
year_code,
year_month,
time_type,
origin_type,
clue_state,
origin_channel,
nums_count
from hive.edu_dm.edu_dm_relationship_count;

insert into hive.edu_rpt.rpt_relationship_department_customer
select
dt,
year_code,
year_month,
time_type,
origin_type,
clue_state,
apartment_name,
nums_count
from hive.edu_dm.edu_dm_relationship_count;
------------------------------------------------------------------
insert into hive.edu_rpt.rpt_clue_day
select
dt,
origin_type,
clue_state,
total_nums
from hive.edu_dws.edu_dws_clue_daycount;

insert into hive.edu_rpt.rpt_clue_hour
select
    hours,
    origin_type,
    clue_state,
    case when nums = 0 then 0
    else round(cast(total_nums as double) / cast(nums as double), 4)
    end as effective_rate
from hive.edu_dws.edu_dws_clue_daycount;

"